package com.kingl.common.core.util;

import lombok.Data;
import org.junit.Test;

import java.io.Serializable;

/**
 * Create by Administrator on 2020/5/18/018
 */
public class ResultJson<Z> implements Serializable {

    private static final long  serialVersionUID = 1L;

    private int code= 200;//http小状态码
    private String msg;//提示信息
    private Z date;//数据详情

    public ResultJson() {
    }

    public ResultJson(int code, String msg, Z date) {
        this.code = code;
        this.msg = msg;
        this.date = date;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Z getDate() {
        return date;
    }

    public void setDate(Z date) {
        this.date = date;
    }

    //传入 data 不指定泛型
    public ResultJson ok(Z date){
        this.date = date;
        return this;
    }

    //传入 data 指定泛型入参
    public ResultJson<Z> okFx(Z date){
        this.date = date;
        return this;
    }

    //传入 data 指定泛型出参和入参
    public <Z> ResultJson<Z> okFxCrParam(Z date){
        ResultJson<Z> resultJson = new ResultJson<Z>();
        resultJson.setDate(date);
        return resultJson;
    }
}
